<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title></title>
    <meta name="keywords" content="">
    <meta name="description" content="">
    <link rel="shortcut icon" href="favicon.ico"> 
	<link href="__PUBLIC__/admin/css/bootstrap.min.css?v=3.3.6" rel="stylesheet">
    <link href="__PUBLIC__/admin/css/font-awesome.css?v=4.4.0" rel="stylesheet">
    <link href="__PUBLIC__/admin/css/style.css?v=4.1.0" rel="stylesheet">
</head>

<script>
var url = "{:url('thcate/lst')}";
var insertUrl = "{:url('thcate/add')}";
var checkCatename = "{:url('thcate/checkCatename')}";
</script>
<body class="gray-bg">
<style>
input.error{
	border:1px solid red;
}
span.error{
	padding-top:10px;
	color: #f00;
	font-size:12px;
}
</style>
    <div class="wrapper wrapper-content">
        <div class="row">
            <div class="col-sm-12">
                <div class="ibox float-e-margins">
                    <div class="ibox-title">
                        <h5>增加退换种类</h5>
                    </div>
                    <div class="ibox-content">
                        <form method="post" class="form-horizontal" id="form">                                                                           
                            <div class="form-group">
                                <label class="col-sm-2 control-label">种类名称</label>
                                <div class="col-sm-6">
                                    <input type="text" name="cate_name" class="form-control">
                                </div>
                            </div>						
                            <div class="hr-line-dashed"></div>  
                            
                            <div class="form-group">
                                <label class="col-sm-2 control-label">描述：</label>
                                <div class="col-sm-6">
                                    <input type="text" name="desc" class="form-control">
                                </div>
                            </div>
                            <div class="hr-line-dashed"></div> 
                            
                            <div class="form-group">
                                <label class="col-sm-2 control-label">是否需要平台已发货：</label>
                                <div class="col-sm-6" id="atype">
                                        <label class="radio-inline"><input type="radio" name="fh_type" value="1">需要</label>
                                        <label class="radio-inline"><input type="radio" name="fh_type" checked="checked" value="0">不需要</label>
                                </div>
                            </div>
                            <div class="hr-line-dashed"></div> 
                            
                            <div class="form-group">
                                <label class="col-sm-2 control-label">是否需要用户退货：</label>
                                <div class="col-sm-6" id="atype">
                                        <label class="radio-inline"><input type="radio" name="tui_type" value="1">需要</label>
                                        <label class="radio-inline"><input type="radio" name="tui_type" checked="checked" value="0">不需要</label>
                                </div>
                            </div>
                            <div class="hr-line-dashed"></div>  
                            
                            <div class="form-group">
                                <label class="col-sm-2 control-label">是否需要平台再次发货：</label>
                                <div class="col-sm-6" id="atype">
                                        <label class="radio-inline"><input type="radio" name="zcfh_type" value="1">需要</label>
                                        <label class="radio-inline"><input type="radio" name="zcfh_type" checked="checked" value="0">不需要</label>
                                </div>
                            </div>
                            <div class="hr-line-dashed"></div>                                                         

                            <div class="form-group">
                                <label class="col-sm-2 control-label">排序</label>
                                <div class="col-sm-6">
                                    <input type="text" name="sort" class="form-control">
                                </div>
                            </div>
                            <div class="hr-line-dashed"></div>
                            
                            <div class="form-group">
                                <label class="col-sm-2 control-label">显示/隐藏：</label>
                                <div class="col-sm-6">
                                        <label class="radio-inline"><input type="radio" name="is_show" checked="checked" value="1">显示</label>
                                        <label class="radio-inline"><input type="radio" name="is_show" value="0">隐藏</label>
                                </div>
                            </div>
                            <div class="hr-line-dashed"></div>                                                                                                  

                            <div class="form-group">
                                <div class="col-sm-4 col-sm-offset-2">
                                    <button class="btn btn-primary" type="submit" id="doSubmit" style="margin-right:20px;">保存</button>
                                    <button type="reset" class="btn btn-default">重置</button>
                                </div>
                            </div>
                        </form>
                    </div>
                </div>
            </div>
        </div>
    </div>

    <!-- 全局js -->
    <script src="__PUBLIC__/admin/js/jquery.min.js?v=2.1.4"></script>
    <script src="__PUBLIC__/admin/js/bootstrap.min.js?v=3.3.6"></script>
    <!-- 自定义js -->
    <script src="__PUBLIC__/admin/js/plugins/layer/layer.min.js"></script>
    <script src="__PUBLIC__/admin/js/plugins/validate/jquery.validate.min.js"></script>	
    <!-- iCheck -->
    <script src="__PUBLIC__/admin/js/plugins/iCheck/icheck.min.js"></script>
    <script src="__PUBLIC__/admin/js/common/ajax.js"></script>

	<script>
    	$(function(){
            $('.i-checks').iCheck({
                checkboxClass: 'icheckbox_square-green',
                radioClass: 'iradio_square-green',
            });

    	    var icon = "<i class='fa fa-times-circle'></i>&nbsp;&nbsp;";
        	$('#form').validate({
	            errorElement : 'span',
	        	debug: true,//只验证不提交表单
	        	//layer ajax提交表单
	            submitHandler:function(){
	               // 序列化 表单数据 后提交 ，太简洁了
	            	post(insertUrl,'POST',$('#form').serialize(),1);
	            	return false;
	            },//这是关键的语句，配置这个参数后表单不会自动提交，验证通过之后会去调用的方法

	        	rules:{
	        	    cate_name:{
	        	    	required:true,
		        		remote : {
		        			url : checkCatename,
		        			type : 'post',
		        			dataType : 'json',
		        			data : {
		        			   cate_name : function () {
		        				  return $('input[name=cate_name]').val();
		        			   }
		        		    }
			        	}
	        	    },
	        		desc:{required:true},
	        		sort:{
	        			required:true,
	        			digits:true
	        	    }

	        	},

	        	messages:{
	        		cate_name:{
	        			required:icon+'必填',
	        			remote:icon+'已存在'
	        		},
	                desc:{required:icon+'必填'},
	                sort:{
	                	required:icon+'必填',
	                	digits:icon+'排序必须是数字'
	                }
	        	}
        	});
      });

      function cl(){
    	  location.href = url;
      }
    </script>

</body>
</html>
